package com.liveneo.adapter.mobile.util;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.dom4j.Element;

import com.liveneo.adapter.webservice.client.zte.video.QueryBySql;

public class MonitorDataUtil {
	/**
	 * @Description:解析LIST为MAP
	 * @param nodes
	 * @return 
	 * @ReturnType:Map<String,Map>
	 * @exception 
	 * @Since:2015-11-16 上午10:02:11
	 * @Author:yleilei
	 */
	public static Map<String, Map> getTypeOneVideoMap(List nodes) {
		Map<String, Map> videoMap = new HashMap<String, Map>();
		if(nodes!=null && nodes.size()>0){
			for (Iterator it = nodes.iterator(); it.hasNext();) {
				Element elm = (Element) it.next();
				Map tmpMap = videoMap.get(elm.element("groupid").getText());
				if (tmpMap != null) {
					tmpMap.put(elm.element("substatus").getText(), elm.element("num").getText());
					videoMap.put(elm.element("groupid").getText(), tmpMap);
				} else {
					Map newTmpMap = new HashMap();
					newTmpMap.put(elm.element("substatus").getText(), elm.element("num").getText());
					videoMap.put(elm.element("groupid").getText(), newTmpMap);
				}
			}
		}
		return videoMap;
	}
	/**
	 * @Description:解析LIST为MAP
	 * @param nodes
	 * @return 
	 * @ReturnType:Map<String,Map>
	 * @exception 
	 * @Since:2015-11-16 上午10:02:11
	 * @Author:yleilei
	 */
	public static Map<String, String> getTypeTwoVideoMap(List nodesSur) {
		Map<String, String> videoSurMap = new HashMap<String, String>();
		if(nodesSur!=null && nodesSur.size()>0){
			for (Iterator it = nodesSur.iterator(); it.hasNext();) {
				Element elm = (Element) it.next();
				videoSurMap.put(elm.element("skillid").getText(), elm.element("num").getText());
			}
		}
		return videoSurMap;
	}
	/**
	 * @Description:解析LIST为MAP
	 * @param nodes
	 * @return 
	 * @ReturnType:Map<String,Map>
	 * @exception 
	 * @Since:2015-11-16 上午10:02:11
	 * @Author:yleilei
	 */
	public static Map<String, String> getTypeThreeVideoMap(List nodesSur) {
		Map<String, String> videoSurMap = new HashMap<String, String>();
		if(nodesSur!=null && nodesSur.size()>0){
			for (Iterator it = nodesSur.iterator(); it.hasNext();) {
				Element elm = (Element) it.next();
				videoSurMap.put("forecast", elm.element("forecast").getText());
				videoSurMap.put("queuecnt", elm.element("queuecnt").getText());
			}
		}
		return videoSurMap;
	}
	/**
	 * @Description:封装对象
	 * @param key
	 * @param vcid
	 * @param sqlid
	 * @param variables
	 * @return 
	 * @ReturnType:QueryBySql
	 * @exception 
	 * @Since:2015-11-16 上午10:01:36
	 * @Author:yleilei
	 */
	public static QueryBySql getQueryBySql(String key, String vcid, String sqlid, String variables) {
		QueryBySql qbsStatus = new QueryBySql();
		qbsStatus.setKey(key);
		qbsStatus.setVcid(vcid);
		qbsStatus.setSqlid(sqlid);
		qbsStatus.setVariables(variables);
		return qbsStatus;
	}
}
